/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package BL;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

/**
 *
 * @author sundas
 */
@Entity
@Table(name = "systemuser", catalog = "newPurchase", schema = "", uniqueConstraints = {@UniqueConstraint(columnNames = {"userId"})})
@NamedQueries({@NamedQuery(name = "Systemuser.findAll", query = "SELECT s FROM Systemuser s"), @NamedQuery(name = "Systemuser.findByUserId", query = "SELECT s FROM Systemuser s WHERE s.userId = :userId"), @NamedQuery(name = "Systemuser.findByUserPassword", query = "SELECT s FROM Systemuser s WHERE s.userPassword = :userPassword")})
public class Systemuser implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "userId", nullable = false, length = 33)
    private String userId;
    @Basic(optional = false)
    @Column(name = "userPassword", nullable = false, length = 33)
    private String userPassword;
    @JoinColumn(name = "NIC", referencedColumnName = "NIC")
    @ManyToOne
    private Person nic;
    @OneToMany(mappedBy = "userId")
    private Collection<Prodorder> prodorderCollection;

    public Systemuser() {
    }

    public Systemuser(String userId) {
        this.userId = userId;
    }

    public Systemuser(String userId, String userPassword) {
        this.userId = userId;
        this.userPassword = userPassword;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getUserPassword() {
        return userPassword;
    }

    public void setUserPassword(String userPassword) {
        this.userPassword = userPassword;
    }

    public Person getNic() {
        return nic;
    }

    public void setNic(Person nic) {
        this.nic = nic;
    }

    public Collection<Prodorder> getProdorderCollection() {
        return prodorderCollection;
    }

    public void setProdorderCollection(Collection<Prodorder> prodorderCollection) {
        this.prodorderCollection = prodorderCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (userId != null ? userId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Systemuser)) {
            return false;
        }
        Systemuser other = (Systemuser) object;
        if ((this.userId == null && other.userId != null) || (this.userId != null && !this.userId.equals(other.userId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "DB.Systemuser[userId=" + userId + "]";
    }

}
